package com.mmren.edu.dtx.controller;

import com.mmren.edu.common.result.CommonResult;
import com.mmren.edu.dtx.service.StockService;
import com.mmren.edu.dtx.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 欢迎来到牧码人教育，做Java我们是专业的
 *
 * @创建人： 牧码人教育-Gerry
 * @创建时间： 2020-4-20
 * @功能描述：
 */
@RestController
@RequestMapping("v1/api/stock")
public class StockController {
    @Autowired
    private StockService stockService;

    @PostMapping
    public CommonResult reduceStock(@RequestBody OrderVO vo) {
        boolean flag = stockService.reduceStock(vo);
        if(flag) {
            return CommonResult.OK();
        } else {
           return CommonResult.NO();
        }
    }
}
